import request from "@/utils/request"

// 引入接口函数 Ts约束
// 注意在vscode当中引入接口对象的时候，一定要加上type来声明一下
import type {
  TrademarkListDataModel,
  TrademarkMode,
} from "./model/trademarkModel"

// 添加枚举 统一管理接口
enum Api {
  getAllTrademarkListApi = "/admin/product/baseTrademark",
  saveTrademarkApi = "/admin/product/baseTrademark/save",
  deleteTrademarkApi = "/admin/product/baseTrademark/remove",
  updateTrademarkApi = "/admin/product/baseTrademark/update",
}

// 1.获取品牌管理页数据
export const reqGetTrademarkListData = (page: number, limit: number) =>
  request.get<any, TrademarkListDataModel>(
    `${Api.getAllTrademarkListApi}/${page}/${limit}`
  )

//2.添加品牌
export const reqSaveTrademarkInfo = (trademark: TrademarkMode) =>
  request.post<any, null>(Api.saveTrademarkApi, trademark)

// 3.删除单件品牌
export const reqDeleteTrademarkInfo = (id: number) =>
  request.delete<any, null>(`${Api.deleteTrademarkApi}/${id}`)

// 4.更新品牌
export const reqUpdateTrademarkInfo = (trademark: TrademarkMode) =>
  request.put<any, null>(Api.updateTrademarkApi, trademark)
